package net.onceface.application.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import net.onceface.application.dto.ProductPictureDTO;
import net.onceface.core.domain.ProductPicture;

public class ProductPictureAssembler {

	public static ProductPictureDTO toDTO(ProductPicture productPicture){
		if(productPicture == null){
			return null;
		}
		ProductPictureDTO result = new ProductPictureDTO();
		result.setAddress(productPicture.getAddress());
		result.setId(productPicture.getId());
		result.setDefaultPic(productPicture.isDefaultPic());
		result.setProductId(productPicture.getProductId());
		result.setVesion(productPicture.getVersion());
		return result;
	}
	
	public static ProductPicture toEntity(ProductPictureDTO productPicture){
		if(productPicture == null){
			return null;
		}
		ProductPicture result = new ProductPicture();
		result.setAddress(productPicture.getAddress());
		result.setId(productPicture.getId());
		result.setDefaultPic(productPicture.isDefaultPic());
		result.setProductId(productPicture.getProductId());
		result.setVersion(productPicture.getVesion());
		return result;
	}
	
	public static List<ProductPicture>  toEntities(Collection<ProductPictureDTO>  productPictures){
		if (productPictures == null) {
			return null;
		}
		List<ProductPicture> results = new ArrayList<ProductPicture>();
		for (ProductPictureDTO each : productPictures) {
			results.add(toEntity(each));
		}
		return results;
	}
	
	public static List<ProductPictureDTO>  toDTOs(Collection<ProductPicture>  productPictures){
		if (productPictures == null) {
			return null;
		}
		List<ProductPictureDTO> results = new ArrayList<ProductPictureDTO>();
		for (ProductPicture each : productPictures) {
			results.add(toDTO(each));
		}
		return results;
	}
}
